package com.jf.test.mvvm

import android.content.Intent
import android.view.View
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.jf.test.mvvm.base.BaseAcVM


/**
 * @Class: MainVM
 * @Description:
 * @author: github.com/jackyflame
 * @Date: 2021/3/5
 */
class MainVM : BaseAcVM<MainActivity,MainAcPresenter>() {

    var testData:MutableLiveData<String> = MutableLiveData();

    fun onTtsClick(view: View){
        testData.value = "test";
        val it = Intent("android.intent.action.MAIN")
        it.setClassName(
            "com.aispeech.fawvw.voice.assist",
            "com.aispeech.fawvw.voice.assist.MainActivity"
        )
        it.putExtra("TTS_TEXT","我从外部调用了TTS")
        //activity?.startActivity(it);
    }

    fun onHttpClick(view: View){
        mPresenter?.getHistory();
    }

    fun  testVM(){
        getActivity()?.testAC();
    }

    override fun initPresenter(owner: LifecycleOwner): MainAcPresenter? {
        return MainAcPresenter(owner as LifecycleOwner,this as ViewModel)
    }

}